<?php
namespace app\admin\validate;
use think\Validate;

/**
 * 用户信息验证器
 * Created by PhpStorm.
 * User: tyll
 * Date: 2019/10/18
 * Time: 11:08
 */
class User extends Validate{

    protected $rule = [
        'username'   => 'require',
        'department' => 'require',
        'position'   => 'require',
        'tel'        => 'require|integer|length:11',
        'role'       => 'require|gt:1',
    ];

    protected $message = [
        'username.require'   => '姓名必须填写',
        'department.require' => '所属部门必须填写',
        'position.require'   => '职位必须填写',
        'tel.require'        => '电话号码必须填写',
        'tel.integer'        => '电话号码填写错误',
        'tel.length'         => '电话号码为11位',
        'role.require'       => '用户角色必须填写',
        'role.gt'            => '不能为超级管理员',
    ];

    protected $scene = [
        'add'  => ['username','department','position','tel','role'],
        'edit' => ['username','department','position','tel','role']
    ];
}